package com.runda.partypolicy.app.page.adapter;


import android.text.Html;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.runda.partypolicy.R;
import com.runda.partypolicy.app.repository.bean.OfficeData;
import com.runda.partypolicy.utils.CheckEmptyUtils;


import java.util.List;

import androidx.annotation.Nullable;

/**
 * author:  RD_YH
 * date:    2019/3/15
 * version: v1.0
 * description:
 */
public class Adapter_OfficeList extends BaseQuickAdapter<OfficeData, BaseViewHolder> {
    OnItemClickListener itemOnClickListener;

    public void setItemOnClickListener(OnItemClickListener itemOnClickListener) {
        this.itemOnClickListener = itemOnClickListener;
    }

    public Adapter_OfficeList(int layoutResId, @Nullable List<OfficeData> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, OfficeData item) {

        if (!CheckEmptyUtils.isEmpty(item.getTitle())) {
            helper.setText(R.id.tv_title, item.getTitle());
        }
        if (!CheckEmptyUtils.isEmpty(item.getTime())) {
            helper.setText(R.id.tv_time, item.getTime());
        }


        switch (item.getType()) {

            case "通知公告":
            case "政务热线":
                helper.getView(R.id.tv_author).setVisibility(View.GONE);
                break;
            case "领导活动安排":
                helper.setText(R.id.tv_author, item.getAuthor());
                helper.setText(R.id.tv_time2, item.getTime());

                helper.getView(R.id.iv_notice).setVisibility(View.VISIBLE);
                helper.getView(R.id.tv_time2).setVisibility(View.VISIBLE);
                helper.getView(R.id.tv_time).setVisibility(View.GONE);
                if (item.isNotice()) {
                    helper.setImageResource(R.id.iv_notice, R.drawable.icon_unnotice);
                } else {
                    helper.setImageResource(R.id.iv_notice, R.drawable.icon_noticed);

                }
                break;
            case "请示报告":
                helper.setText(R.id.tv_author, "请示单位：" + item.getAuthor());
                break;
            case "公文批阅":
                helper.setText(R.id.tv_author, "发文单位：" + item.getAuthor());
                break;
            case "工作专报":
                helper.setText(R.id.tv_author, "签发人：" + item.getAuthor());
                helper.getView(R.id.tv_middle).setVisibility(View.VISIBLE);
                String str2 = "<font color='#FF0000'>8</font>/10 已阅";
                helper.setText(R.id.tv_middle, Html.fromHtml(str2));

                break;
        }


    }
}
